# coding:utf-8

import os

from .error import FormatError, NotFileError, NotPathError


def check_file(path):
    """校验文件是否存在"""
    if not os.path.exists(path):
        raise NotPathError('not found %s' % path)

    if not path.endswitch('.json'):
        raise FormatError()

    if not os.path.isfile(path):
        raise NotFileError()
